home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / EXTMEM.LZH / XMEMC.C < prev    next >
Text File  |  1987-09-14  |  1KB  |  52 lines

  1. #include <dos.h>
  2.  
  3. static char ident[] = "VDISK  V3.2";
  4.  
  5. unsigned long get_loc( void )
  6. {
  7. unsigned far *int19_seg = MK_FP( 0x0000, 4*0x19+2 );
  8. char far *txt_ptr;
  9. char *lcl_ptr;
  10. unsigned far *lo;
  11. unsigned char far *hi;
  12.  
  13.     /* VDISK's identification string is located in
  14.         the same segment as the int 0x19 handler, at
  15.         offset 0x12. */
  16.  
  17.     txt_ptr = MK_FP( *int19_seg, 0x12 );
  18.     lcl_ptr = ident;
  19.     while ( *lcl_ptr != 0 )
  20.         if ( *lcl_ptr++ != *txt_ptr++ )
  21.             return( 0x100000U );
  22.  
  23.     /* if VDISK is installed, the address
  24.         of the first byte of available extended
  25.         memory space is stored in the same segment
  26.         as the int 0x19 handler, at offset 0x2C,
  27.         0x2D, and 0x2E. */
  28.     lo = MK_FP( *int19_seg, 0x2C );
  29.     hi = MK_FP( *int19_seg, 0x2E );
  30.  
  31.     /* convert the address into a long */
  32.     return( (unsigned long)*hi * 65536L + (unsigned long)*lo );
  33. }
  34.  
  35. #if defined( TEST )
  36.  
  37. #include <stdio.h>
  38.  
  39. unsigned int get_size( void );
  40.  
  41. void main()
  42. {
  43. unsigned long mem_size;
  44. unsigned long first_loc;
  45.  
  46.     first_loc = get_loc();
  47.     mem_size = (unsigned long)get_size()*1024 - ( first_loc - 0x100000L );
  48.     printf( "First loc = 0x%lX\nSize = %luK\n", first_loc, mem_size/1024 );
  49. }
  50.  
  51. #endif /* TEST */
  52.